
/****************************************************************************
A sample configuration structure
	The entire structure is 31 bits long.
	The first 10 bits (LSB) are dedicated to 
	specifying the required sampling frequency.
	This sampling frequency is remains constant 
	whilst the configuration is current. 
	The second sampling frequency measure is a counter.
	This counter is set or decremented by the sampling
	process. 
	The next 3 bits indicates if the sampling description 
	is in frequency or period.
	The next 4 bits (MSB) are used for 
	a sample ID. To indicate which pin to obtain the 
	sample from. 
	The last 4 bits are tell the proces how many other 
	samples of like units there are to be sampled.

	the 10 bits used to specify the sampling periodOrFrequency gives a 
	maximum possible sampling periodOrFrequency of 1024. This can be 
	in a number of possible units (kHz, Hz, ms, s, m, h). 
****************************************************************************/
typedef union
{
	unsigned long sampleConfiguration;
	struct
	{
		unsigned SampleUnit						:3;	//Unit the sample periodOrFrequency is measured in.
														//		000 = 		Delete Frequency
														//		001 = us	(micro seconds)
														//		010 = ms 	(milli seconds)
														//		011 = s		(seconds)
														//		100 = m 	(minutes)
														//		101 = h		(hour)
														//		110 = d		(Day)
														//		111	= Y		(Year))
		unsigned SamplePeriodOrFrequency		:10; //The sampling frequency or sampling period of the signal
		
		unsigned RxDeadlineUnit	 				:3;	//Unit the sample periodOrFrequency is measured in.
														//		000 = 		Delete Frequency
														//		001 = us	(micro seconds)
														//		010 = ms 	(milli seconds)
														//		011 = s		(seconds)
														//		100 = m 	(minutes)
														//		101 = h		(hour)
														//		110 = d		(Day)
														//		111	= Y		(Year)
		unsigned RxDeadline						:10;//The maximum allowable period between sample aquisition and reception.
		
		unsigned sampleID						:4;	//Channel to take sample from.
														//		1111 = chanel 15
														//		1110 = chanel 14
														//		....
														//		0001 = chanel 1
														//		0000 = chanel 0
		
		unsigned 								:1;	//Reserved
										
	}s;
}SampleConfigurationType;

/****************************************************************************
A function to Modify current sampling configuration

input:
		a sample configuration structure.

output:
		an integer indicating if the configuration 
		modification was successful
			0 	= configuration was successfull
			>0 	= an error occured.
****************************************************************************/
int modifyConfiguration(SampleConfigurationType * sampConfig);


//A function that handles the ADC configuration
//	Configurations get sent to the ADC via a queue.
//	This function waits to receive new configurations via the queue.
//
//	When a configuration is received the function must determine if
//	1. A current configuration needs to be updated.
//	2. An existing configuration needs to be deleted
//	3. If a new configuration needs to be created.
//	
//	Once this has been decided the function calls the appropriate
//	method to peform the operation needed.
//	
//	The function will then allert the scheduler of the update.
void ConfigHandler_HandleConfiguration( void * pvParameters );
